# client.py
import socket

phone = socket.socket()
phone.connect(('192.168.114.129', 6666))
while True:
    info = input('>>').strip()
    # 当发送的数据长度为0时，服务端和客户端都会进入等待收数据的阻塞阶段，所以进行判断，判断用户输入的信息被strip处理后，长度是否为0
    if len(info) == 0:
        continue
    if info == 'q':
        break
    phone.send(info.encode('utf-8'))
    data = phone.recv(1024)
    print('服务端', data.decode('utf-8'))

phone.close()